package com.ssy.invoicing.customer.service;

import java.sql.SQLException;
import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.ssy.invoicing.customer.bean.CustomerBean;
import com.ssy.invoicing.customer.dao.CustomerDao;
import com.ssy.invoicing.dao.support.BaseSqlDao.SplitPageResult;

/**
 * Comment of CustomerService
 * @author suoyao.shen
 */
@Service(value="customerService")
@Transactional
public class CustomerService {
    
    @Resource(name="customerDao")
    private CustomerDao customerDao;

    /**
     * 查询客户信息
     * @author suoyao.shen
     * @return
     * @throws SQLException
     */
    public SplitPageResult queryCustomerList(Integer page) throws SQLException {
        return customerDao.queryCustomerList(null, page == null ? 1 : page.intValue());
    }
    
    /**
     * 查询客户详情
     * @author suoyao.shen
     * @param id
     * @return
     */
    public CustomerBean getCustomer(Integer id) {
        return customerDao.getCustomer(id);
    }
    
    /**
     * 删除客户信息
     * @author suoyao.shen
     * @param id
     */
    public void removeCustomer(Integer id) {
        customerDao.removeCustomer(id);
    }
    
    /**
     * 根据客户类型查询客户列表
     * @author suoyao.shen
     * @param type
     * @return
     */
    public List<CustomerBean> queryCustomerByType(Integer type) {
        return customerDao.queryCustomerByType(type);
    }
    
    /**
     * 保存客户信息
     * @author suoyao.shen
     * @param customer
     */
    public void saveCustomer(CustomerBean customer) {
        customerDao.saveCustomer(customer);
    }
    
    /**
     * 更新客户信息
     * @author suoyao.shen
     * @param customer
     */
    public void updateCustomer(CustomerBean customer) {
        customerDao.updateCustomer(customer);
    }
    
}
